package com.jm.controller;

import com.jm.domain.ResponseResult;
import com.jm.domain.entity.Role;
import com.jm.domain.entity.User;
import com.jm.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("system/user")
public class UserController {
    @Autowired
    private UserService userService;

    @GetMapping("/list")
    public ResponseResult list(Integer pageNum, Integer pageSize, String userName, String phonenumber, String status) {
        return userService.listUser(pageNum, pageSize, userName, phonenumber, status);
    }

    @PostMapping
    public ResponseResult save(@RequestBody User user){
        return userService.saveUser(user);
    }

    @DeleteMapping("/{id}")
    public ResponseResult delete(@PathVariable Long id){
        return userService.deleteUser(id);
    }

    @GetMapping("/{id}")
    public ResponseResult getUserById(@PathVariable Long id){
        return userService.getUserById(id);
    }

    @PutMapping
    public ResponseResult update(@RequestBody User user){
        return userService.updateUser(user);
    }

}
